package com.maslyk.invitation.page;

import java.util.HashMap;
import java.util.Map;

import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;

import org.apache.myfaces.trinidad.context.RequestContext;

import com.maslyk.invitation.enums.ViewIdentityEnum;
import com.maslyk.invitation.to.SessionDataTO;

public class PopupHelper {

	@SuppressWarnings("unchecked")
	public static void showPopup(ViewIdentityEnum viewId) {
		FacesContext context = FacesContext.getCurrentInstance();
		// Create the dialog UIViewRoot
		ViewHandler viewHandler = context.getApplication().getViewHandler();
		UIViewRoot dialog = viewHandler.createView(context, "/popup_window.jsp");

		SessionDataTO.setCurrentPopupView(viewId);

		Map properties = new HashMap();
		properties.put("width", new Integer(300));
		properties.put("height", new Integer(100));

		RequestContext requestContext = RequestContext.getCurrentInstance();
		requestContext.launchDialog(dialog, null,
				null, // no particular parameters
				true, // show it in a dialog
				properties);
		
	}

}
